package com.iflytek.ci.cpms.service.util;

import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.iflytek.ci.common.utils.excel.FormatContentParser;
import com.iflytek.ci.qams.dto.IssueExcel;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-1-14
 * Time: 下午4:20
 * To change this template use File | Settings | File Templates.
 */
public class IssueImportExcelParser implements FormatContentParser{
    /**
     * 所有的Excel人员信息
     */
    private List<IssueExcel> issueExcelList = Lists.newArrayList();
    /**
     * 每行的人员信息
     */
    private IssueExcel  line_issueExcel;

    @Override
    public <T> Object getResult() {
        return issueExcelList;
    }

    @Override
    public void newLine(int lineNumber) {
        line_issueExcel = new IssueExcel();
        issueExcelList.add(line_issueExcel);
    }

    @Override
    public void parseUnit(int x, int y, String content) {
        //是否为空
        boolean content_empty = Strings.isNullOrEmpty(content);
        if (!content_empty) {
            content = content.trim();
        } else {
            content="null";
        }
        switch (x) {
            case 0:
                line_issueExcel.setSn(content);
                break;
            case 1:
                line_issueExcel.setNo(content);
                break;
            case 2:
                line_issueExcel.setTitle(content);
                break;
            case 3:
                line_issueExcel.setProject(content);
                break;
            case 4:
                line_issueExcel.setModule(content);
                break;
            case 5:
                line_issueExcel.setFind_way(content);
                break;
            case 6:
                line_issueExcel.setSeverity(content);
                break;
            case 7:
                try{
                     line_issueExcel.setPriopity(content.substring(0,content.indexOf("-")));
                }
                catch(Exception e){
                    line_issueExcel.setPriopity("gggg");

                }
                break;
            case 8:
                line_issueExcel.setStatus(content);
                break;
            case 9:
                line_issueExcel.setResolve_way(content);
                break;
            case 10:
                line_issueExcel.setAssigner(content);
                break;
            case 11:
                line_issueExcel.setUpdate_date(content);
                break;
            case 12:
                line_issueExcel.setDuration(content);
                break;
            case 13:
                line_issueExcel.setCreator(content);
                break;
            case 14:
                line_issueExcel.setCreate_date(content);
                break;
            case 15:
                line_issueExcel.setFind_version(content);
                break;
            case 16:
                line_issueExcel.setResolve_version(content);
                break;
            default:
                break;
        }
    }

}
